package concurrent;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.LockSupport;

/**
 * @author chenxin
 * @time 2017-02-21-16:52
 */
public class CountDownLatchTest {
    public static void main(String[] args) throws Exception{
        int count = 10;
        final CountDownLatch countDownLatch = new CountDownLatch(count);

        for(int i = 0; i < count; i++){
            new Thread(new Runnable() {
                public void run(){
                    System.out.println("thread");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    countDownLatch.countDown();
                }
            }).start();
        }

        countDownLatch.await();
        System.out.println("test");

//        Object obj = new Object();
//        LockSupport.park(obj);
//        System.out.println("test");
    }
}
